import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: "/",
    redirect: "/login",
  },
  {
    path: "/login",
    name: "足浴票务开放平台",
    component: () =>
      import(/* webpackChunkName: "about" */ "./views/Login.vue"),
  },
  {
  	path: "/goodsDetail",
  	name: "商品详情",
  	component: () =>
  	  import(/* webpackChunkName: "fans" */ "./views/home/goodsDetail.vue"),
  },
  {
  	path: "/recharge",
  	name: "足浴充值",
  	component: () =>
  	  import(/* webpackChunkName: "fans" */ "./views/my/recharge.vue"),
  },
  {
    path: "/wrapper",
    component: () =>
      import(/* webpackChunkName: "about" */ "./components/Wrapper"),
    children: [{
        path: "/home",
        name: "home",
        component: () =>
          import(/* webpackChunkName: "manage" */ "./views/home/home.vue"),
        meta: { isShowTabbar: true }
      }, {
        path: "/orderList",
        name: "orderList",
        component: () =>
          import(/* webpackChunkName: "fans" */ "./views/order/orderList.vue"),
        meta: { isShowTabbar: true }
      }, {
        path: "/orderStatistics",
        name: "orderStatistics",
        component: () =>
          import(/* webpackChunkName: "fans" */ "./views/order/orderStatistics.vue"),
        meta: { isShowTabbar: true }
      },
	  {
	  	path: "/balance",
	  	name: "余额明细",
	  	component: () =>
	  	  import(/* webpackChunkName: "fans" */ "./views/my/balance.vue"),
		   meta: { isShowTabbar: true }
	  },
    ],
  },
];

const router = new VueRouter({
  routes
})
// 路由守卫
router.beforeEach((to,from,next)=>{
  // if(!to.meta.isShowTabbar) {
  //   document.title = to.name;
  // }
  document.title = to.name;
  next();
  // if(to.matched.some(res=>res.meta.isLogin)){//判断是否需要登录
  //     if (sessionStorage['username']) {
  //         next();
  //     }else{
  //         next({
  //             path:"/login",
  //             query:{
  //                 redirect:to.fullPath
  //             }
  //         });
  //     }

  // }else{
  //     next()
  // }
});
export default router
